package com.hyt.it.ogt.ks.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.ks.config.ConfigManager;
import com.hyt.it.ogt.ks.enums.BizStatusCode;
import com.hyt.it.ogt.ks.feign.TpsClient;
import com.hyt.it.ogt.ks.model.vo.AppDownAddressVO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import io.swagger.annotations.ApiSort;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * app下载接口
 * @author 刘恒活
 * @since 2020/8/24 10:12
 */
@RestController
@RequestMapping("/ks/app/")
@CrossOrigin
@Api(tags = "17.app下载接口", value = "app下载接口")
@ApiSort(17)
@Slf4j
public class AppController {
    @Resource
    private ConfigManager configManager;
    @Resource
    private TpsClient tpsClient;

    @ApiOperation(value = "17.1.1 获取app下载地址", notes = "20000:成功", response = AppDownAddressVO.class)
    @ApiOperationSort(1)
    @GetMapping("getAppDownAddress")
    public ApiResponse getAppDownAddress() {
        return ApiResponse.builder().code(BizStatusCode.KS_SUCCESS_OK.getCode())
                .data(AppDownAddressVO.builder()
                        .androidUrl(configManager.getAndroidDownloadUrl())
                        .androidVersion(configManager.getAndroidVersion())
                        .iosUrl(configManager.getIosDownloadUrl())
                        .iosVersion(configManager.getIosVersion())
                        .build()).build();
    }

    @ApiOperation(value = "17.1.2 获取人脸核身参数", notes = "20000:成功", response = AppDownAddressVO.class)
    @ApiOperationSort(2)
    @GetMapping("getFaceApp")
    public ApiResponse getFaceApp(@RequestParam String idCard, @RequestParam String name) {
        return ApiResponse.builder().code(BizStatusCode.KS_SUCCESS_OK.getCode())
                .data(tpsClient.getFaceApp(idCard, name)).build();
    }

}

